//
//
//  TableViewController.m
//  TheRoadAD
//
//  Created by baixue on 16/8/4.
//  Copyright © 2016年 baixue. All rights reserved.
//


#import "TableViewController.h"
//#import "MJRefresh.h"
#import "ComChannelCell.h"
#import "MorePicture.h"
#import "ActivistTableViewController.h"//维权
#import "SearchView.h"

#define TITLE @[@"美图秀秀",@"趣味视频",@"聚焦维权"]
#define TITLEBTN @[@"更多美图》",@"更多视频》",@"更多维权》"]
@interface TableViewController ()<UITableViewDelegate>

@end

@implementation TableViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"ComChannelCell" bundle:nil] forCellReuseIdentifier:@"ComChannelCell"];
    self.tableView.delegate = self;
    self.tableView.tableFooterView = [[UIView alloc]init];

//    self.edgesForExtendedLayout = UIRectEdgeNone;
//    __typeof (self) __weak weakSelf = self;
    
//    self.tableView.footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//        // 进入刷新状态后会自动调用这个block
//        [weakSelf delayInSeconds:1.0 block:^{
//            weakSelf.itemNum += 4;
//            [weakSelf.tableView.footer endRefreshing];
//            [weakSelf.tableView reloadData];
//        }];
//    }];
    
}

- (void)delayInSeconds:(CGFloat)delayInSeconds block:(dispatch_block_t) block
{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC),  dispatch_get_main_queue(), block);
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _itemNum;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    ComChannelCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ComChannelCell"];
    
    switch (indexPath.row) {
        case 1:
            cell.videoPlay1.hidden = NO;
            cell.videoPlay2.hidden = NO;
            cell.videoPlay3.hidden = NO;
            cell.videoPlay4.hidden = NO;
            cell.meitu1.image = [UIImage imageNamed:@"shipin1"];
            cell.meitu2.image = [UIImage imageNamed:@"shipin2"];
            cell.meitu3.image = [UIImage imageNamed:@"shipin3"];
            cell.meitu4.image = [UIImage imageNamed:@"shipin4"];
            break;
        case 2:
            cell.meitu1.image = [UIImage imageNamed:@"weiquan1"];
            cell.meitu2.image = [UIImage imageNamed:@"weiquan2"];
            cell.meitu3.image = [UIImage imageNamed:@"weiquan3"];
            cell.meitu4.image = [UIImage imageNamed:@"weiquan4"];
            break;
            
        default:
            break;
    }
    cell.titleLable.text = TITLE[indexPath.row];
    [cell.IconPictures setTitle:TITLEBTN[indexPath.row] forState:0];
    //更多按钮
    cell.BlockMore = ^(){
        MorePicture *m = [[MorePicture alloc] init];
        m.index = indexPath.row;
        [self.navigationController pushViewController:m animated:YES];
    };

    //详情
    cell.BlockImage = ^(NSInteger tag){
        ActivistTableViewController *a = [[ActivistTableViewController alloc]init];
        [self.navigationController pushViewController:a animated:YES];
        };
        return cell;
}



@end
